import React, { Component } from 'react'

class Navbar extends Component {
  render() {
    return (
      <div style={{width:'100%', background:'red'}}>
          <button onClick={()=>{
              this.props.event();    //子传父子组件指令，()不要忘记
          }}>子传父</button>
      </div>
    )
  }
}

class Sidebar extends Component {
  render() {
    return (
      <div style={{width:'50%', background:'yellow',height:'200px'}}>
          111
      </div>
    )
  }
}

export default class App extends Component {
    state = {
        isShow:true
    }
  render() {
    return (
      <div>
          <Navbar event={()=>{     //子传父父组件指令
              this.setState({
                  isShow:!this.state.isShow
              })
          }}></Navbar>
          {this.state.isShow && <Sidebar></Sidebar>}
      </div>
    )
  }
}
